package com.pgytesting.mobilecertpay.util;

import lombok.extern.slf4j.Slf4j;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @version v1.0
 * @ProjectName: MobileCertPay
 * @ClassName: ResponseMassage
 * @Description: TODO(返回消息头)
 * @Author: sunbo@pgytesting.cn
 * @Date: 2019/3/11 18:18
 */
@Slf4j
public class ResponseMassage {


    private static final String PARAM_SUCCESS = "00";

    private static final String ANSWER_CODE_STR = "{" +
            "\"10010\":{\"respCode\":\"10010\",\"respMsg\":\"余额不足\"}," +
            "\"10036\":{\"respCode\":\"10036\",\"respMsg\":\"订单状态异常\"}," +
            "\"10000\":{\"respCode\":\"10000\",\"respMsg\":\"参数不合法\"}," +
            "\"10007\":{\"respCode\":\"10007\",\"respMsg\":\"商户编号不存在\"}," +
            "\"10011\":{\"respCode\":\"10011\",\"respMsg\":\"需开通银联无卡支付功能\"}," +
            "\"10024\":{\"respCode\":\"10024\",\"respMsg\":\"姓名、身份证、银行卡或手机号信息不一致\"}," +
            "\"10025\":{\"respCode\":\"10025\",\"respMsg\":\"金额超限\"}," +
            "\"10026\":{\"respCode\":\"10026\",\"respMsg\":\"账户不存在\"}," +
            "\"10028\":{\"respCode\":\"10028\",\"respMsg\":\"账户状态异常\"}," +
            "\"10032\":{\"respCode\":\"10032\",\"respMsg\":\"您输入的验证码有误，请确认后重新输入。\"}," +
            "\"10034\":{\"respCode\":\"10034\",\"respMsg\":\"认证失败\"}," +
            "\"10037\":{\"respCode\":\"10037\",\"respMsg\":\"支付渠道系统繁忙，请稍后再试\"}," +
            "\"10038\":{\"respCode\":\"10038\",\"respMsg\":\"支付失败，请稍后再试\"}," +
            "\"10039\":{\"respCode\":\"10039\",\"respMsg\":\"支付次数超过发卡银行限制，本次支付失败\"}," +
            "\"10040\":{\"respCode\":\"10040\",\"respMsg\":\"暂不支持此类型银行卡，请更换其他银行卡\"}," +
            "\"10042\":{\"respCode\":\"10042\",\"respMsg\":\"金额超过月累计限额\"}," +
            "\"10043\":{\"respCode\":\"10043\",\"respMsg\":\"支付金额小于最低限制\"}," +
            "\"10044\":{\"respCode\":\"10044\",\"respMsg\":\"银行卡预留手机号验证不通过\"}," +
            "\"10045\":{\"respCode\":\"10045\",\"respMsg\":\"银行卡验证次数超限，请明日再试\"}," +
            "\"10046\":{\"respCode\":\"10046\",\"respMsg\":\"户名有误\"}," +
            "\"10047\":{\"respCode\":\"10047\",\"respMsg\":\"账号有误\"}," +
            "\"10048\":{\"respCode\":\"10048\",\"respMsg\":\"交易要素不完整，请核实后再试\"}," +
            "\"10049\":{\"respCode\":\"10049\",\"respMsg\":\"交易失败，详情请咨询发卡行\"}," +
            "\"10050\":{\"respCode\":\"10050\",\"respMsg\":\"余额不足次数过多\"}," +
            "\"10051\":{\"respCode\":\"10051\",\"respMsg\":\"当日失败次数过多，请24小时后再试\"}," +
            "\"10052\":{\"respCode\":\"10052\",\"respMsg\":\"支付金额不在可支付金额范围内，或者银行卡不支持\"}," +
            "\"10053\":{\"respCode\":\"10053\",\"respMsg\":\"支付次数过多，请24小时后再试\"}," +
            "\"10054\":{\"respCode\":\"10054\",\"respMsg\":\"交易超时，请重新提交\"}," +
            "\"20000\":{\"respCode\":\"20000\",\"respMsg\":\"系统异常，请稍后重试\"}," +
            "\"30001\":{\"respCode\":\"30001\",\"respMsg\":\"金额超过单笔限额\"}," +
            "\"30002\":{\"respCode\":\"30002\",\"respMsg\":\"金额超过日累计限额\"}," +
            "\"00100\":{\"respCode\":\"00100\",\"respMsg\":\"查询卡bin失败\"}," +
            "\"00101\":{\"respCode\":\"00101\",\"respMsg\":\"交易超出限额/次数\"}," +
            "\"00003\":{\"respCode\":\"00003\",\"respMsg\":\"订单已失效，请重新发起支付\"}," +
            "\"00004\":{\"respCode\":\"00004\",\"respMsg\":\"验证处理中，请求已提交银行处理，请稍后再重新发起验证\"}," +
            "\"00005\":{\"respCode\":\"00005\",\"respMsg\":\"您已绑了一张银行卡，请解绑原卡，再使用新卡支付\"}," +
            "\"00007\":{\"respCode\":\"00007\",\"respMsg\":\"请输入支付金额\"}," +
            "\"00009\":{\"respCode\":\"00009\",\"respMsg\":\"支付金额不在规定范围内\"}," +
            "\"00020\":{\"respCode\":\"00020\",\"respMsg\":\"请输入银行卡卡号\"}," +
            "\"00021\":{\"respCode\":\"00021\",\"respMsg\":\"请输入银行预留手机号\"}," +
            "\"00022\":{\"respCode\":\"00022\",\"respMsg\":\"请输入姓名\"}," +
            "\"00023\":{\"respCode\":\"00023\",\"respMsg\":\"请输入身份证号\"}," +
            "\"00024\":{\"respCode\":\"00024\",\"respMsg\":\"姓名、身份证信息不匹配\"}," +
            "\"00028\":{\"respCode\":\"00028\",\"respMsg\":\"验证码失效\"}," +
            "\"00031\":{\"respCode\":\"00031\",\"respMsg\":\"请输入短信验证码\"}," +
            "\"00038\":{\"respCode\":\"00038\",\"respMsg\":\"用户未绑卡，无需解绑\"}," +
            "\"00039\":{\"respCode\":\"00039\",\"respMsg\":\"该卡已被绑定过，不能重复绑卡\"}," +
            "\"00041\":{\"respCode\":\"00041\",\"respMsg\":\"暂不支持该银行\"}," +
            "\"00063\":{\"respCode\":\"00063\",\"respMsg\":\"银行系统升级中，请您稍后再试\"}," +
            "\"00071\":{\"respCode\":\"00071\",\"respMsg\":\"用户id不能为空\"}," +
            "\"00072\":{\"respCode\":\"00072\",\"respMsg\":\"商户订单号不能为空\"}," +
            "\"00082\":{\"respCode\":\"00082\",\"respMsg\":\"订单信息有误\"}," +
            "\"00086\":{\"respCode\":\"00086\",\"respMsg\":\"该笔订单已支付成功，无需重复支付\"}," +
            "\"00090\":{\"respCode\":\"00090\",\"respMsg\":\"您输入的支付信息与您绑定的信息不符\"}," +
            "\"00096\":{\"respCode\":\"00096\",\"respMsg\":\"用户注册失败，请重试。\"}," +
            "\"00102\":{\"respCode\":\"00102\",\"respMsg\":\"需解绑卡与已绑定卡信息不符\"}," +
            "\"00103\":{\"respCode\":\"00103\",\"respMsg\":\"关单时间最短5分钟\"}," +
            "\"10001\":{\"respCode\":\"10001\",\"respMsg\":\"请求参数有误\"}," +
            "\"10002\":{\"respCode\":\"10002\",\"respMsg\":\"非法请求\"}," +
            "\"10009\":{\"respCode\":\"10009\",\"respMsg\":\"订单不存在\"}," +
            "\"00099\":{\"respCode\":\"00099\",\"respMsg\":\"用户不存在\"}," +
            "\"10027\":{\"respCode\":\"10027\",\"respMsg\":\"银行通讯异常\"}," +
            "\"10031\":{\"respCode\":\"10031\",\"respMsg\":\"未开通该产品\"}," +
            "\"20003\":{\"respCode\":\"20003\",\"respMsg\":\"通讯异常\"}," +
            "\"20004\":{\"respCode\":\"20004\",\"respMsg\":\"验证码校验次数超限\"}," +
            "\"20006\":{\"respCode\":\"20006\",\"respMsg\":\"验证码发送次数超限\"}," +
            "\"20007\":{\"respCode\":\"20007\",\"respMsg\":\"验证码发送失败\"}," +
            "\"20008\":{\"respCode\":\"20008\",\"respMsg\":\"验证码验证失败\"}," +
            "\"20009\":{\"respCode\":\"20009\",\"respMsg\":\"验证码过期失效\"}," +
            "\"00087\":{\"respCode\":\"00087\",\"respMsg\":\"订单正在支付处理中，请勿重复提交!\"}," +
            "\"99999\":{\"respCode\":\"99999\",\"respMsg\":\"未定义错误类型\"}," +
            "\"99024\":{\"respCode\":\"99024\",\"respMsg\":\"服务调用异常\"}," +
            "\"99020\":{\"respCode\":\"99020\",\"respMsg\":\"签名校验失败\"}," +
            "\"99011\":{\"respCode\":\"99011\",\"respMsg\":\"未知的系统错误\"}," +
            "\"99012\":{\"respCode\":\"99012\",\"respMsg\":\"数据验证错误\"}," +
            "\"99016\":{\"respCode\":\"99016\",\"respMsg\":\"参数无效\"}," +
            "\"99018\":{\"respCode\":\"99018\",\"respMsg\":\"白名单验证失败\"}," +
            "\"99019\":{\"respCode\":\"99019\",\"respMsg\":\"白名单用户不存在\"}," +
            "\"99021\":{\"respCode\":\"99021\",\"respMsg\":\"service不存在\"}," +
            "\"99022\":{\"respCode\":\"99022\",\"respMsg\":\"signkey不存在\"}," +
            "\"99023\":{\"respCode\":\"99023\",\"respMsg\":\"verifysignfailure\"}," +
            "\"99025\":{\"respCode\":\"99025\",\"respMsg\":\"转发URL异常\"}," +
            "\"99026\":{\"respCode\":\"99026\",\"respMsg\":\"参数异常\"}," +
            "\"99027\":{\"respCode\":\"99027\",\"respMsg\":\"service为空\"}," +
            "\"99028\":{\"respCode\":\"99028\",\"respMsg\":\"merchantId为空\"}," +
            "\"99029\":{\"respCode\":\"99029\",\"respMsg\":\"商户密钥不存在\"}," +
            "\"99030\":{\"respCode\":\"99030\",\"respMsg\":\"防重复请求码校验失败\"}," +
            "\"99031\":{\"respCode\":\"99031\",\"respMsg\":\"服务版本号version错误\"}," +
            "\"99032\":{\"respCode\":\"99032\",\"respMsg\":\"请求IP非法\"}," +
            "\"99033\":{\"respCode\":\"99033\",\"respMsg\":\"数据解密失败\"}," +
            "\"99034\":{\"respCode\":\"99034\",\"respMsg\":\"数据加密失败\"}}";


    public static Map<String, Object> getResMassage(String paramStr) {
        Map jsonMap;
        if (PARAM_SUCCESS.equals(paramStr)) {
            Map<String, Object> map = new LinkedHashMap<>();
            map.put("respCode", PARAM_SUCCESS);
            map.put("respMsg", "请求成功");
            return map;
        }
        log.info("对返回参数进行格式化");
        jsonMap = UtilMethod.StringToJson(ANSWER_CODE_STR);
        log.info("返回获取的错误码");
        return UtilMethod.StringToJson(String.valueOf(jsonMap.get(paramStr)));
    }

    public static Map<String, Object> getResMassage(Object data) {
        Map<String, Object> map = new LinkedHashMap<>();
        map.put("respCode", PARAM_SUCCESS);
        map.put("respMsg", "请求成功");
        map.put("data", data);
        return map;
    }

}
